using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace DuplexTransformers
{
    public class LeftListExpression<TLeft, TRight, TLeftPropItem> : LeftExpression<TLeft, TRight, IList<TLeftPropItem>>
    {
        public LeftListExpression(Transformer<TLeft, TRight> transformer, Expression<Func<TLeft, IList<TLeftPropItem>>> expr) : base(transformer, expr)
        {
        }

        public PropertyRelationshipTransformerExpression<TLeft, TRight, IList<TLeftPropItem>, IList<TRightPropItem>> TransformedBy<TRightPropItem>(ITransformer<TLeftPropItem, TRightPropItem> transformer)
        {
            var listMediator = new ListTransformer<TLeftPropItem, TRightPropItem>(transformer);
            return new PropertyRelationshipTransformerExpression<TLeft, TRight, IList<TLeftPropItem>, IList<TRightPropItem>>(x => Transformer.AddRelationship(x), WrappedExpr, listMediator);
        }
    }
}